﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Simple.Repository.Migrations
{
    public partial class _48 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.UpdateData(
                table: "Recipes",
                keyColumn: "RecipeName",
                keyValue: null,
                column: "RecipeName",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "RecipeName",
                table: "Recipes",
                type: "longtext",
                nullable: false,
                comment: "食谱名",
                oldClrType: typeof(string),
                oldType: "longtext",
                oldNullable: true,
                oldComment: "食谱名")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "MCheck_Record",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    ChildrenId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "学生Id", collation: "ascii_general_ci"),
                    BodyTemperature = table.Column<decimal>(type: "decimal(65,30)", nullable: false, comment: "体温"),
                    ThroatType = table.Column<int>(type: "int", nullable: true, comment: "咽喉类型"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MCheck_Record", x => x.Id);
                },
                comment: "晨检记录")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "MedicationRegister",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    ChildId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "幼儿id", collation: "ascii_general_ci"),
                    MedicationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "服药时间"),
                    ClassId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "班级", collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "longtext", nullable: true, comment: "药物名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Explain = table.Column<string>(type: "longtext", nullable: true, comment: "说明")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ParentId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "家长id", collation: "ascii_general_ci"),
                    Relationship = table.Column<int>(type: "int", nullable: true, comment: "家属关系"),
                    State = table.Column<int>(type: "int", nullable: false, comment: "状态"),
                    TeacherId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "确认人", collation: "ascii_general_ci"),
                    ConfirmedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "确认时间"),
                    RescindedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "撤销时间"),
                    RejectTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "驳回时间"),
                    RejectReason = table.Column<string>(type: "longtext", nullable: true, comment: "驳回理由")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MedicationRegister", x => x.Id);
                },
                comment: "服药登记")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "PlanWeekRecipes",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    PlanName = table.Column<string>(type: "longtext", nullable: false, comment: "计划食谱名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PlanRange = table.Column<string>(type: "longtext", nullable: false, comment: "食谱周期")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    StarTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "开始时间"),
                    EndTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "结束时间"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PlanWeekRecipes", x => x.Id);
                },
                comment: "每周计划食谱")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "MedicationRegisterImage",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    FiledId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "文件Id", collation: "ascii_general_ci"),
                    FileName = table.Column<string>(type: "longtext", nullable: false, comment: "文件名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FileSize = table.Column<string>(type: "longtext", nullable: false, comment: "文件大小")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MedicationRegisterId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "班级动态Id", collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MedicationRegisterImage", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MedicationRegisterImage_MedicationRegister_MedicationRegiste~",
                        column: x => x.MedicationRegisterId,
                        principalTable: "MedicationRegister",
                        principalColumn: "Id");
                },
                comment: "服药登记图片表")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "PlanDayRecipes",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    PlanWeekRecipesId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "每周计划食谱id", collation: "ascii_general_ci"),
                    Data = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "日期（：2023-01-01）"),
                    DataStr = table.Column<string>(type: "longtext", nullable: false, comment: "日期（：星期一）")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ClassId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "班级Id", collation: "ascii_general_ci"),
                    SysClassesId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Number = table.Column<int>(type: "int", nullable: false, comment: "就餐人数"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PlanDayRecipes", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PlanDayRecipes_PlanWeekRecipes_PlanWeekRecipesId",
                        column: x => x.PlanWeekRecipesId,
                        principalTable: "PlanWeekRecipes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PlanDayRecipes_SysClasses_SysClassesId",
                        column: x => x.SysClassesId,
                        principalTable: "SysClasses",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "每日计划食谱")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "PlanDayRecipesDetail",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    PlanDayRecipesId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "每日计划食谱id", collation: "ascii_general_ci"),
                    RecipesId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "食谱id", collation: "ascii_general_ci"),
                    Type = table.Column<int>(type: "int", nullable: false, comment: "类型"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PlanDayRecipesDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PlanDayRecipesDetail_PlanDayRecipes_PlanDayRecipesId",
                        column: x => x.PlanDayRecipesId,
                        principalTable: "PlanDayRecipes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PlanDayRecipesDetail_Recipes_RecipesId",
                        column: x => x.RecipesId,
                        principalTable: "Recipes",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "每日计划食谱详情")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_MedicationRegisterImage_MedicationRegisterId",
                table: "MedicationRegisterImage",
                column: "MedicationRegisterId");

            migrationBuilder.CreateIndex(
                name: "IX_PlanDayRecipes_PlanWeekRecipesId",
                table: "PlanDayRecipes",
                column: "PlanWeekRecipesId");

            migrationBuilder.CreateIndex(
                name: "IX_PlanDayRecipes_SysClassesId",
                table: "PlanDayRecipes",
                column: "SysClassesId");

            migrationBuilder.CreateIndex(
                name: "IX_PlanDayRecipesDetail_PlanDayRecipesId",
                table: "PlanDayRecipesDetail",
                column: "PlanDayRecipesId");

            migrationBuilder.CreateIndex(
                name: "IX_PlanDayRecipesDetail_RecipesId",
                table: "PlanDayRecipesDetail",
                column: "RecipesId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "MCheck_Record");

            migrationBuilder.DropTable(
                name: "MedicationRegisterImage");

            migrationBuilder.DropTable(
                name: "PlanDayRecipesDetail");

            migrationBuilder.DropTable(
                name: "MedicationRegister");

            migrationBuilder.DropTable(
                name: "PlanDayRecipes");

            migrationBuilder.DropTable(
                name: "PlanWeekRecipes");

            migrationBuilder.AlterColumn<string>(
                name: "RecipeName",
                table: "Recipes",
                type: "longtext",
                nullable: true,
                comment: "食谱名",
                oldClrType: typeof(string),
                oldType: "longtext",
                oldComment: "食谱名")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");
        }
    }
}
